package com.example.pcl.controller.counselor;


import com.example.pcl.constant.MessageConstants;
import com.example.pcl.pojo.dto.ConsultationRecordDTO;
import com.example.pcl.pojo.dto.ConsultationRecordQueryDTO;
import com.example.pcl.result.PageResult;
import com.example.pcl.result.Result;
import com.example.pcl.service.IConsultationRecordsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 咨询记录表，记录每次咨询的详细情况 前端控制器
 * </p>
 *
 * @author xx
 * @since 2024-12-17
 */
@RestController("counselorConsultationRecordsController")
@RequestMapping("/user/counselor/consultation-records")
@Slf4j
@RequiredArgsConstructor
@Tag(name = "管理端心理咨询师咨询记录相关接口")
public class ConsultationRecordsController {


    private final IConsultationRecordsService consultationRecordsService;

    /**
     * 按条件查询咨询记录
     *
     * @param queryDTO 查询条件
     * @return 符合条件的咨询记录列表
     */
    @GetMapping("/list")
    @Operation(summary = "按条件查询咨询记录")
    public Result<PageResult<?>> queryConsultationRecords(ConsultationRecordQueryDTO queryDTO) {
        log.info("心理咨询师按条件查询咨询记录: {}", queryDTO);
        return Result.success(consultationRecordsService.queryConsultationRecords(queryDTO), MessageConstants.SELECT_OK);
    }

    /**
     * 用户查询咨询记录详细
     *
     * @param id 预约 id
     * @return 实体
     */
    @GetMapping("/detail/{id}")
    @Operation(summary = "心理咨询师查询咨询记录详细")
    public Result<?> detail(@PathVariable Integer id) {
        log.info("心理咨询师查询咨询记录详细:{}", id);
        return Result.success(consultationRecordsService.finByAppointmentId(id), MessageConstants.SELECT_OK);
    }

    /**
     * 修改咨询记录
     *
     * @param recordDTO 修改的咨询记录数据
     * @return 操作结果
     */
    @PutMapping("/update")
    @Operation(summary = "修改咨询记录")
    public Result<?> updateConsultationRecord(@RequestBody @Validated ConsultationRecordDTO recordDTO) {
        log.info("心理咨询师修改咨询记录: {}", recordDTO);
        consultationRecordsService.updateConsultationRecord(recordDTO);
        return Result.success(MessageConstants.OPERATION_SUCCESSFUL);
    }
}
